package com.zxt.mapper;

import com.zxt.pojo.Emp;
import com.zxt.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

    // 不用pagehelper插件的方法
   // @Select("select e.* ,d.name deptName from emp e left join dept d on e.dept_id=d.id order by e.entry_date desc limit #{start},#{pageSize} ")
//      @Select("select emp.* ,dept.name from emp left join dept on emp.dept_id=dept.id order by emp.entry_date desc  ")
   // List<Emp> getEmpList(Integer start , Integer pageSize);

    //不用pagehelper插件的方法
    // @Select("select count(*) from emp left join dept on emp.dept_id=dept.id ")
    // Long total();
    // @Select("select count(*) from emp left join dept on emp.dept_id=dept.id ")



   //比较复杂 定义在了 xml文件中
    List<Emp> getEmpList(EmpQueryParam param);


//    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
//            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addEmp(Emp emp);

    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void update(Emp emp);

    @MapKey("pos")
    List<Map<String,Object>>getJob();

    List<Map<String, Object>> getGender();


    //登录
@Select("select id,username,name from emp where username=#{username} and password=#{password}")
    Emp selectByUserameAndPassord(Emp emp);
    /**
     * 统计各个职位的员工人数
     */
//    @MapKey("pos")
//    List<Map<String,Object>> countEmpJobData();
}
